package tgc.edu.ljc.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OrderBy;

import com.fasterxml.jackson.annotation.JsonIgnore;

import tgc.edu.ljc.custom.BaseEntity;

@Entity
public class Course extends BaseEntity<Integer> {
	//private Integer id;
	private String name;
	@JsonIgnore
	List<Student> students=new ArrayList<>();
	
//	@Id
//	@GeneratedValue(strategy=GenerationType.IDENTITY)
//	public Integer getId() {
//		return id;
//	}
//
//	public void setId(Integer id) {
//		this.id = id;
//	}
	
	@Column(length=20)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@ManyToMany
	@JoinTable(name="student_course",joinColumns= {@JoinColumn(name="course_id")},inverseJoinColumns= {@JoinColumn(name="student_id")})
	@OrderBy(value="stuNum")
	public List<Student> getStudents() {
		return students;
	}

	public void setStudents(List<Student> students) {
		this.students = students;
	}
	
	
}
